package com.xsomnus.rpc.common.entity;

import com.xsomnus.rpc.common.util.IdUtil;
import lombok.Data;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

/**
 * @author @xsomnus666_xiawenye★
 * @since 2019-04-22 22:00
 */
@Data
public class User {

    private String id;

    private String name;

    private String email;

    private int age;

    private boolean locked;

    private Address address;

    public static User random() {
        User user = new User();
        user.setId(IdUtil.getId());
        user.setAge(RandomUtils.nextInt(1, 1000));
        user.setEmail(RandomStringUtils.randomAlphabetic(5, 12) + "@qq.com");
        user.setName(RandomStringUtils.randomAlphabetic(5, 12));
        user.setLocked(RandomUtils.nextBoolean());
        Address address = new Address();
        address.setProvince(RandomStringUtils.randomAlphabetic(4));
        address.setCity(RandomStringUtils.randomAlphabetic(5));
        address.setDistrict(RandomStringUtils.randomAlphabetic(3));
        address.setZipCode(RandomUtils.nextInt(1, 400000));
        user.setAddress(address);
        return user;
    }
}
